package com.cloud.custom.workflow.time;

import java.util.Date;

import com.cloud.custom.common.utils.DateHelper;
import com.cloud.custom.workflow.enums.TimeUnitEnum;

/**
 * 正常计时
 * 
 * @author taominglong
 *
 */
public class TimeCaclNormalStrategy implements TimeCaclStrategy {

	@Override
	public String getTimeChar(int limit, TimeUnitEnum timeUnit) {
		return limit + timeUnit.getTimeUnitName();
	}

	@Override
	public Date getTimeAfterUnit(int limit, Date now, TimeUnitEnum timeUnit) {
		if (timeUnit == TimeUnitEnum.DAY) {
			return DateHelper.getDateBeforeOrAfterDays(now, limit);
		} else if (timeUnit == TimeUnitEnum.WEEK) {
			return DateHelper.getDateBeforeOrAfterDays(now, limit * 7);
		} else if (timeUnit == TimeUnitEnum.HOUR) {
			return DateHelper.getDateBeforeOrAfterHours(now, limit * 7);
		}
		return now;
	}

}
